<template>
  <div id="contain">
<!--    测试参数传递-->
<!--    <div>{{$route.params.account}}</div>-->

    <div>
      <h2 class="user-info">用户基本信息</h2>
      <div class="cellRow">
        <el-row>
          <el-col :span="6" align="right" style="padding-right: 20px;">用户名:</el-col>
          <el-col :span="18">{{ userInfo_2.account }}</el-col>
        </el-row>
      </div>
      <div class="cellRow">
        <el-row>
          <el-col :span="6" align="right" style="padding-right: 20px;">密码:</el-col>
          <el-col :span="18">{{ userInfo_2.password }}</el-col>
        </el-row>
      </div>
      <div class="cellRow">
        <el-row>
          <el-col :span="6" align="right" style="padding-right: 20px;">真实姓名:</el-col>
          <el-col :span="18">{{ userInfo_2.name }}</el-col>
        </el-row>
      </div>
      <div class="cellRow">
        <el-row>
          <el-col :span="6" align="right" style="padding-right: 20px;">性别:</el-col>
          <el-col :span="18">{{ userInfo_2.gender }}</el-col>
        </el-row>
      </div>
      <div class="cellRow">
        <el-row>
          <el-col :span="6" align="right" style="padding-right: 20px;">身份证号:</el-col>
          <el-col :span="18">{{ userInfo_2.idCard }}</el-col>
        </el-row>
      </div>
      <div class="cellRow">
        <el-row>
          <el-col :span="6" align="right" style="padding-right: 20px;">联系电话:</el-col>
          <el-col :span="18">{{ userInfo_2.userPhoneNum }}</el-col>
        </el-row>
      </div>
      <div class="cellRow">
        <el-row>
          <el-col :span="6" align="right" style="padding-right: 20px;">邮箱:</el-col>
          <el-col :span="18">{{ userInfo_2.mail }}</el-col>
        </el-row>
      </div>
      <div class="cellRow">
        <el-row>
          <el-col :span="6" align="right" style="padding-right: 20px;">职务:</el-col>
          <el-col :span="18"><span>{{ userInfo_2.post }}</span></el-col>
        </el-row>
      </div>
    </div>

    <div>
      <div id="tbHeader">
        <h2 class="relatedQualifications">相关资质查看</h2>
        <!--      <h6 class="validTime">有效期至</h6>-->
      </div>
      <div>
        <div class="cellRow">
          <el-row>
            <el-col :span="6" align="right" style="padding-right: 20px;">企业类型:</el-col>
            <el-col :span="18">{{ userInfo_2.kind }}</el-col>
          </el-row>
        </div>
        <div class="cellRow">
          <el-row>
            <el-col :span="6" align="right" style="padding-right: 20px;">企业名称:</el-col>
            <el-col :span="18">{{ userInfo_2.companyName }}</el-col>
          </el-row>
        </div>
        <div class="cellRow">
          <el-row>
            <el-col :span="6" align="right" style="padding-right: 20px;">注册地区:</el-col>
            <el-col :span="18">{{ userInfo_2.comRegisterArea }}</el-col>
          </el-row>
        </div>
        <div class="cellRow">
          <el-row>
            <el-col :span="6" align="right" style="padding-right: 20px;">邮政编码:</el-col>
            <el-col :span="18">{{ userInfo_2.comPostalCode }}</el-col>
          </el-row>
        </div>
        <div class="cellRow">
          <el-row>
            <el-col :span="6" align="right" style="padding-right: 20px;">企业联系电话:</el-col>
            <el-col :span="18">{{ userInfo_2.comPhoneNum }}</el-col>
          </el-row>
        </div>
        <div class="cellRow">
          <el-row>
            <el-col :span="6" align="right" style="padding-right: 20px;">传真:</el-col>
            <el-col :span="18">{{ userInfo_2.fax }}</el-col>
          </el-row>
        </div>
        <div class="cellRow">
          <el-row>
            <el-col :span="6" align="right" style="padding-right: 20px;">法人代表:</el-col>
            <el-col :span="18">{{ userInfo_2.legalPersonName }}</el-col>
          </el-row>
        </div>
        <div class="cellRow">
          <el-row>
            <el-col :span="6" align="right" style="padding-right: 20px;">法人代表身份证号:</el-col>
            <el-col :span="18">{{ userInfo_2.legalIDCard }}</el-col>
          </el-row>
        </div>
        <div class="cellRow">
          <el-row>
            <el-col :span="6" align="right" style="padding-right: 20px;">企业简介:</el-col>
            <el-col :span="18">
              <el-input
                  id="input1"
                  type="textarea"
                  aria-required="true"
                  v-model="userInfo_2.companyProfile"
                  maxlength="265"
                  show-word-limit
                  clearable
                  readonly

              >
              </el-input>
            </el-col>
          </el-row>
        </div>
        <div class="cellRow">
          <el-row>
            <el-col :span="6" align="right" style="padding-right: 20px;">开户银行:</el-col>
            <el-col :span="18">{{ userInfo_2.bankName }}</el-col>
          </el-row>
        </div>
        <div class="cellRow">
          <el-row>
            <el-col :span="6" align="right" style="padding-right: 20px;">银行账号:</el-col>
            <el-col :span="18">{{ userInfo_2.bankAccount }}</el-col>
          </el-row>
        </div>
        <div class="cellRow">
          <el-row>
            <el-col :span="6" align="right" style="padding-right: 20px;">传真:</el-col>
            <el-col :span="18">{{ userInfo_2.fax }}</el-col>
          </el-row>
        </div>
        <div class="cellRow">
          <el-row>
            <el-col :span="6" align="right" style="padding-right: 20px;">法人代表身份证正面照:</el-col>
            <el-col :span="15">{{  }}</el-col>
            <el-col :span="3">
              <a class="el-link el-link--primary is-underline" :href="link"
                     @click="downLoad(``,userInfo_2.legalIDCardFrontFile)"
              >
                <span class="el-link--inner">文件下载</span>
              </a>
            </el-col>
          </el-row>
        </div>
        <div class="cellRow">
          <el-row>
            <el-col :span="6" align="right" style="padding-right: 20px;">法人代表身份证背面照:</el-col>
            <el-col :span="15">{{  }}</el-col>
            <el-col :span="3">
              <a class="el-link el-link--primary is-underline" :href="link"
                     @click="downLoad(``,userInfo_2.legalIDCardBackFile)"
              >
                <span class="el-link--inner">文件下载</span>
              </a>
            </el-col>
          </el-row>
        </div>
        <div class="cellRow">
          <el-row>
            <el-col :span="6" align="right" style="padding-right: 20px;">统一社会信用代码照:</el-col>
            <el-col :span="15">{{ }}</el-col>
            <el-col :span="3">
               <a class="el-link el-link--primary is-underline" :href="link"
                     @click="downLoad(``,userInfo_2.USCCFile)"
              >
                <span class="el-link--inner">文件下载</span>
              </a>
            </el-col>
          </el-row>
        </div>
      </div>
    </div>

    <div>
        <h2 class="audit">审核</h2>
        <div id = "auditDiv">
          <el-row>
            <el-col :span="6">
              <div id="leftDiv">
                <span>审核意见:</span>
              </div>
            </el-col>
            <el-col :span="18">
              <div id="rightDiv">
                <el-input
                    id="input2"
                    type="textarea"
                    aria-required="true"
                    placeholder="请输入审核意见，必填,最大限制100字"
                    v-model="userInfo_2.message"
                    maxlength="100"
                    show-word-limit
                    clearable
                >
                </el-input>
              </div>
            </el-col>
          </el-row>
        </div>
        <div id="auditButton">
          <el-button type="success" @click="pass">通过</el-button>
          <el-button type="danger" @click="reject">驳回</el-button>
          <el-button type="info" @click="turnBack">返回</el-button>
        </div>
      </div>

    </div>
</template>

<script>
// import axios from "axios";

export default {
  name: "AuditSingleUser",
  data(){
    return{
      //测设用数据
/*      userInfo:{
        account: '',
        password:'',
        name:'',
        gender:'',
        idCard:'',
        userPhoneNum:'',
        mail:'',
        post:'',
        legalIDCardFrontFile:'454',
        legalIDCardBackFile:'545',
        USCCFile:'49',
        kind:'',
        companyName:'',
        comRegisterArea:'',
        comPostalCode:'',
        comPhoneNum:'',
        fax:'',
        legalPersonName:'',
        legalIDCard:'',
        companyProfile:'',
        bankName:'',
        bankAccount:'',
        message:'',
        status:0
      },*/
      //实际使用数据
      userInfo_2:{},
      link:''
    }
  },
  methods:{
    getUserInfo(){
      this.$axios({
            url: '/Test/auditor/getUserInfo.do',
            method:'post',
            headers:{'Content-Type': 'application/x-www-form-urlencoded'},
            params:{
                account:this.$route.params.userAccount
            }
          }).then((response)=>{
          console.log('这是返回的response',response)
          this.userInfo_2 = response.data
        });
    },
    pass(){
      if(this.userInfo_2.message !== ''){
        alert('恭喜你通过了')
        this.userInfo_2.status = 1
        this.postUserInfo()
        this.$router.push({path:'/AuditAll'})
      }else{
        alert('请输入审核意见!!!!')
      }
    },
    reject(){
      if(this.userInfo_2.message != ''){
        alert('你被拒绝了，拒绝的原因是：')
        alert(this.userInfo_2.message)
        this.userInfo_2.status = -1
        this.postUserInfo()
        this.$router.push({path:'/AuditAll'})
      }else{
        alert('请输入审核意见!!!!')
      }
    },
    turnBack(){
      alert('返回上一级菜单')
      this.userInfo_2.status = 0
      this.$router.push({path:'/AuditAll'})
    },
    postUserInfo(){
      let data = {
        message: this.userInfo_2.message,
        status: this.userInfo_2.status
      }
      this.$axios({
        url:'/Test/auditor/sendJudge.do',
        method:'post',
        params:{
          message: this.userInfo_2.message,
          status: this.userInfo_2.status},
        headers:{'Content-Type': 'application/x-www-form-urlencoded'}
      }).then((response)=>{
        alert("请求成功")
        console.log(response)
      }).catch((error)=>{
        alert('请求失败')
        console.log(error)
      })
    },
    //有关文件图片下载
    /*    fileDownload(url){
          console.log(url)
          const xhr = new XMLHttpRequest()
          xhr.open('GET',url)
          xhr.responseType = 'blob'
          xhr.send()
          xhr.onload = function (){
            const fileBlob = xhr.response
            console.log(fileBlob)
            //将blob转换成url
            const fileUrl = URL.createObjectURL(fileBlob)
            console.log(fileUrl)
            const elementA = document.getElementById('download_1')
            elementA.setAttribute('href',fileUrl)
            elementA.setAttribute('download','')
          }
        },*/
    /*    downLoad(url) {
          this.$axios({
            method: "GET",
            url: url,
            responseType: "blob"
          }).then(res => {
            const {data,headers} = res
            let blob = new Blob([data], { type: headers['content-type'] })
            let new_url = window.URL.createObjectURL(blob);
            window.location.href = new_url;
          });
        }*/
    downLoad(url,fileName){
      var path=fileName.split('\\');
      var name1=path[path.length-1];
      var name2='';
      if(name1.search("legalIDCardFrontFile")!=-1){
        name2="legalIDCardFrontFile"
      }else if(name1.search("legalIDCardBackFile")!=-1){
        name2="legalIDCardBackFile"
      }else if(name1.search("USCCFile")!=-1){
        name2="USCCFile"
      }
      this.link="/Test/auditor/downloadInfo.do?fileName="+name2;
    }
  },
  //初始话的时候加载
  created() {
    this.getUserInfo()
  }
}
</script>

<style scoped>
.user-info{
  color: #00a1ff;
  border-bottom: 1px solid #1e95ce;
  text-align: left;
  font-size: 16px;
  padding: 6px 0px;
}
.cellRow{
  padding-bottom: 10px;
  margin-bottom: 10px;
  border-bottom: gray 1px dashed;
  margin-top: 10px;
  /*display: flex;*/
}
.relatedQualifications{
  color: #00a1ff;
  /*border-bottom: 1px solid #1e95ce;*/
  text-align: left;
  font-size: 16px;
  padding: 6px 0px;
  margin-bottom: 0;
}
.cellRow{
  padding-bottom: 10px;
  margin-bottom: 10px;
  border-bottom: gray 1px dashed;
  margin-top: 10px;
}
#tbHeader{
  border-bottom: 1px solid #1e95ce;
}
/deep/ #input1 {
  height: 200px;
  margin: 0;
  width: 500px;
  resize: none;
}
.audit{
  color: #00a1ff;
  border-bottom: 1px solid #1e95ce;
  text-align: left;
  font-size: 16px;
  padding: 6px 0;
}
#leftDiv{
  align-content: center;
  text-align: right;
  margin-top: 30px;
  margin-right: 17px;
}
#rightDiv{
  margin-left: 3px;
  margin-top: 30px;
}
#auditDiv{
  border-bottom: 1px dashed gray;
  padding-bottom: 50px;
}
#auditButton{
  margin-top: 30px;
  display: flex;
  justify-content: center;
}
/deep/ #input2 {
  height: 100px;
  margin: 0;
  width: 500px;
  resize: none;
}
</style>